import java.util.Scanner;

public class demo01 {
    //k倍区间
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[] arr=new int[n];
        long sum=0;
        long count=0;
        long[] arr1=new long[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
            sum+=arr[i];
            arr1[(int)(sum%k)]++;
        }
        count+=arr1[0];
        for (int i = 0; i < k; i++) {
            count+=(arr1[i]*(arr1[i]-1))/2;
        }
        System.out.println(count);

    }
}
